<?php
require_once 'database.php';
class role{
	var $id;
	var $type;
	public function __construct($id,$type){
		$this->id=$id;
		$this->type=$type;
	}
	public function getID(){
		return $this->id;
	}
	public function getType(){
		return $this->type;
	}
	public function displayNotifications(){
		$db = new DatabaseManager();
		$connection = $db->getDB();
		$query="select t1 from registered where id='".$this->getID()."'";
		$result=mysqli_query($connection,$query);
		if(mysqli_num_rows($result)>=1){
			$temp = mysqli_fetch_array($result,MYSQLI_ASSOC);
			$i=(int)$temp['t1'];
			if($this->getType()=='phd'){
				if($i%10){
				echo "<div id=\"message-green\">
				<table border=\"0\" width=\"100%\" cellpadding=\"0\" cellspacing=\"0\">
				<tr>
					<td class=\"green-left\">Request approved! <a href=\"archive.php\">More information</a></td>
					<td class=\"green-right\"><a class=\"close-green\"><img src=\"../images/table/icon_close_green.gif\"   alt=\"\" /></a></td>
				</tr>
				</table>
			</div>";
			}
			$i/=10;
			if($i%10){
				echo "<div id=\"message-red\">
				<table border=\"0\" width=\"100%\" cellpadding=\"0\" cellspacing=\"0\">
				<tr>
					<td class=\"red-left\">Request Rejected <a href=\"archive.php\">More information</a></td>
					<td class=\"red-right\"><a class=\"close-red\"><img src=\"../images/table/icon_close_red.gif\"   alt=\"\" /></a></td>
				</tr>
				</table>
			</div>";
			}
			$i/=10;
			if($i%10){
				echo "<div id=\"message-yellow\">
				<table border=\"0\" width=\"100%\" cellpadding=\"0\" cellspacing=\"0\">
				<tr>
					<td class=\"yellow-left\">Your request(s) has approved by your advisor <a href=\"table.php\">Go to pending requests.</a></td>
					<td class=\"yellow-right\"><a class=\"close-yellow\"><img src=\"../images/table/icon_close_yellow.gif\"   alt=\"\" /></a></td>
				</tr>
				</table>
			</div>";
			}
			}elseif($this->getType()=='adv'){
				if($i%10){
				echo "<div id=\"message-yellow\">
				<table border=\"0\" width=\"100%\" cellpadding=\"0\" cellspacing=\"0\">
				<tr>
					<td class=\"yellow-left\">Some request(s) await your approval <a href=\"table.php\">Go to pending requests.</a></td>
					<td class=\"yellow-right\"><a class=\"close-yellow\"><img src=\"../images/table/icon_close_yellow.gif\"   alt=\"\" /></a></td>
				</tr>
				</table>
			</div>";
			}
						
				
				}
			
		}
		$query="update registered set t1='0' where id='".$this->id."'";
		$result=mysqli_query($connection,$query);
	
		
		
	}
	/*function homepage(){
		$data = array(
			"name" => "",
			"balance" => "",
			"renewdate" => ""
		);
		$connection=DatabaseManager::getDB();
		$query = "SELECT name,date_of_joining FROM phd WHERE phd_id='".$this->getID()."'";
		$result = mysqli_query($connection,$query);
		$temp = mysqli_fetch_array($result,MYSQLI_ASSOC);
		$data['name']=$temp['name'];
		$data['renewdate']= strtotime('+1 years',$temp['data_of_joining']);
		$query = "SELECT balance FROM account WHERE pid='".$this->getID()."'";
		$result = mysqli_query($connection,$query);
		$temp = mysqli_fetch_array($result,MYSQLI_ASSOC);
		$data['balance']=$temp['balance'];
		return $data;
	}*/
}
?>